package cate.game.role.farm.rank;

import cate.common.table.d.GDOperation;
import cate.common.table.rank.row.IRewardRankRow;
import cate.game.client.msg.MergeMsgSender;
import cate.game.rank.IRewardRankObj;
import cate.game.res.MixRes;
import cate.game.role.Role;
import cate.game.role.RoleDependent;
import easy.java.dev.note.NoteField;

import java.util.HashMap;
import java.util.Map;

public class UnrealRankObj extends RoleDependent implements IRewardRankObj{
    @NoteField(value = "奖励领取记录")
    public Map<Integer, Boolean> rewardGot;

    @NoteField(value = "排行榜ID")
    public int rankId;

    public UnrealRankObj(){

    }

    public UnrealRankObj(Role role, int rankId){
        super(role);
        this.rankId = rankId;
        initialize(role);
    }

    @Override
    public void initialize(Role role){
        super.initialize(role);
        if(rewardGot == null){
            rewardGot = new HashMap<>();
        }
    }

    @Override
    public Map<Integer,Boolean> getRewardsMap() {
        return rewardGot;
    }

    @Override
    public MixRes getRankReward(IRewardRankRow row, boolean notice, MergeMsgSender sender) {
        MixRes reward = new MixRes(row.getRewardStr());
        reward.add(role, true, GDOperation.RANK_REWARD, sender);
        rewardGot.put(row.getRewardId(), true);
        if (notice) {
            role.getGame().notice.dialogReward(role, reward);
        }
        return reward;
    }

    @Override
    public boolean isOpen() {
        return true;
    }

    @Override
    public void checkOpen() {

    }
}
